# -*- coding: utf-8 -*-

# Copyright (C) 2009 Nik Lutz <nik.lutz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA


from PyQt4.QtCore import *
from PyKDE4.kdecore import *
from NagiosObjects import *
from PyKDE4.kdecore import *


class FilterConfig(object):
    """
        The place for central configuration.
    """
    def __init__(self, **kwds):
        """
            read config file and set the appropriate attributes
        """
        # supposed to be sensible defaults

        self.update_interval = 1
        self.short_display = False
        self.long_display = True
        self.filter_all_down_hosts = "False"
        self.filter_all_unreachable_hosts = "False"
        self.filter_all_unknown_services = "False"
        self.filter_all_warning_services = "False"
        self.filter_all_critical_services = "False"
        self.filter_acknowledged_hosts_services = "False"
        self.filter_hosts_services_disabled_notifications = "False"
        self.filter_hosts_services_disabled_checks = "False"
        self.filter_hosts_services_maintenance = "False"
        self.filter_services_on_down_hosts = "False"
        self.filter_services_on_unreachable_hosts = "False"
        self.filter_services_in_soft_state = "False"
        self.position_x = 0
        self.position_y = 0
        self.popup_details_hover = "True"
        self.popup_details_clicking = "False"
        self.connect_by_dns_yes = "True"
        self.connect_by_dns_no = "False"
        self.debug_mode = "False"
    
    def fromDict(self, aDict):
        for k in aDict: 
            self.__dict__[k] = aDict[k]

class NagiosJob(KJob):
    server = None

    def __init__(self, server):
        KJob.__init__(self)
        self.server = server

    def start(self):
        QTimer.singleShot( 0, self.doWork )

    def doWork(self):
        try:
            self.server.GetStatus()
        except Exception ,e :
            print e
        self.emitResult()



